﻿@using DonutMgmtSystemFoundation.Models
@using System.Configuration
@using ViewRes

@model SendMailModel

@section Title{
    @Admin.SendMails
}

@section Pagename{
    <i class="mail icon"></i>@Admin.SendMails
}

@section Scripts{
    <script type="text/javascript">
        $(function () {
            $('.ui.accordion').accordion();

            $(".ui.submit.button").click(function () {
                var form = $(this).parent();
                var url = form.attr('data-post');

                var data = $(form).find(":input").serialize();

                $.ajax({
                    type: "POST",
                    dataType: "json",
                    data: data,
                    url: url,
                    beforeSend: function () {
                        $("#message-icon").removeClass("red").removeClass("green").removeClass("remove").removeClass("checkmark")
                        $("#message").html("");
                        $("#loader").addClass("active");
                    },
                    success: function updateFields(data) {
                        if (data.Success) {
                            $("#message-icon").addClass("green").addClass("checkmark");
                        } else {
                            $("#message-icon").addClass("red").addClass("remove");
                        }
                        $("#message").html(data.Message);
                        $('#dimmerContent').dimmer('show');
                    },
                    complete: function () {
                        $("#loader").removeClass("active");
                    }
                });
            });
        });
    </script>
}

<div class="ui grid">
    <div class="row">
        <div class="ten column wide">
            <div class="ui fluid accordion">
                <div class="title">
                    <i class="dropdown icon"></i>@Admin.SendPayment
                </div>
                <div class="content">
                    <div class="ui form" data-post="@Url.Action("SendPaymentMail", "Admin")">
                        <div class="field">
                            <label>@Admin.Subject</label>
                            <input type="text" name="Subject" value="@Model.Payment.Subject" />
                        </div>
                        <div class="field">
                            <label>@Admin.To</label>
                            <input type="text" name="To" value="@Model.Payment.To" />
                        </div>
                        <div class="field">
                            <label>@Admin.Bcc</label>
                            <input type="text" name="Bcc" value="@Model.Payment.Bcc" />
                        </div>
                        <div class="ui green submit button">@Admin.Send</div>
                    </div>
                </div>
            </div>
            <div class="ui fluid accordion">
                <div class="title">
                    <i class="dropdown icon"></i>@Admin.SendDonutsArrived
                </div>
                <div class="content">
                    <div class="ui form" data-post="@Url.Action("SendDonutsArrivedMail","Admin")">
                        <div class="field">
                            <label>@Admin.Subject</label>
                            <input type="text" name="Subject" value="@Model.Remainder.Subject" />
                        </div>
                        <div class="field">
                            <label>@Admin.To</label>
                            <input type="text" name="To" value="@Model.Remainder.To" />
                        </div>
                        <div class="field">
                            <label>@Admin.Bcc</label>
                            <input type="text" name="Bcc" value="@Model.Remainder.Bcc" />
                        </div>
                        <div class="ui green submit button">@Admin.Send</div>
                    </div>
                </div>
            </div>
            <div class="ui fluid accordion">
                <div class="title">
                    <i class="dropdown icon"></i>@Admin.SendOrder
                </div>
                <div class="content">
                    <div class="ui form" data-post="@Url.Action("SendOrderMail","Admin")"> 
                        <div class="field">
                            <label>@Admin.To</label>
                            <input type="text" name="To" value="@Model.Order.To" />
                        </div>
                        <div class="field">
                            <label>@Admin.Bcc</label>
                            <input type="text" name="Bcc" value="@Model.Order.Bcc" />
                        </div>
                        <div class="ui green submit button">@Admin.Send</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- Message Dimmer -->
<div class="ui page dimmer" id="dimmerContent">
    <div class="content">
        <div class="center">
            <h2 class="ui inverted icon header">
                <i id="message-icon" class="icon circular inverted emphasized"></i>
                <span id="message"></span>
            </h2>
        </div>
    </div>
</div>

<!-- Loader -->
<div id="loader" class="ui page dimmer">
    <div class="ui large text loader">@Shared.Loading</div>
</div>
